import { View } from "@tarojs/components";
import dayjs from "dayjs";
import { useEffect, useState } from "react";
import { AtCard } from "taro-ui";
import { getAllNotice } from "../../api/notice";
import "./index.scss";
import avater from "../../image/avater.png";
export default () => {
  const [dataList, SetDataList] = useState<any[]>();
  useEffect(() => {
    getAllNotice().then(resp => {
      SetDataList(resp);
    });
  }, []);

  const showhtml = htmlString => {
    var html = { __html: htmlString };
    return <View dangerouslySetInnerHTML={html}></View>;
  };
  return (
    <View>
      {dataList &&
        dataList.map(item => {
          return (
            <View style={{ margin: "10px 0" }}>
              <AtCard
                note={"最总解释权归主办方所有"}
                extra={dayjs(item.createTime).format("YYYY/MM/DD")}
                title={item.noticeTitle}
                thumb={avater}
              >
                {showhtml(item.noticeContent)}
              </AtCard>
            </View>
          );
        })}
    </View>
  );
};
